package keeto.com.vn.bms.ui.adapter;

import java.util.ArrayList;

import keeto.com.vn.bms.ui.activity.R;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class IconCallAdapter extends BaseAdapter{
	private ArrayList<Drawable> icons;
	private Context mContext;
	private LayoutInflater inflater;
	ArrayList<String> names;

	public IconCallAdapter(ArrayList<Drawable> icons,ArrayList<String> names, Context mContext) {
		super();
		this.names=names;
		this.icons = icons;
		this.mContext = mContext;
		inflater=LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return icons.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return icons.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if(convertView==null){
			holder= new ViewHolder();
			convertView=inflater.inflate(R.layout.item_call, parent, false);
			holder.imgCall=(ImageView)convertView.findViewById(R.id.img_call);
			holder.tvNameApp=(TextView)convertView.findViewById(R.id.tv_appName);
			convertView.setTag(holder);
		}
		else{
			holder=(ViewHolder)convertView.getTag();
		}
		holder.imgCall.setBackgroundDrawable(icons.get(position));
		holder.tvNameApp.setText(names.get(position));
		
		return convertView;
	}
	class ViewHolder{
		ImageView imgCall;
		TextView tvNameApp;
	}
	



}
